package fem2.pre_and_post;

import java.util.ArrayList;
import java.util.StringTokenizer;

import org.junit.Test;

import fem2.Debugger;
import fem2.MeshGenerator;

public class GidMeshGeneratorTest {

	@Test
	public void testSplit() {
		String a = "    asdffg safaf    ";
		String[] b = a.split("[ ]+");
		for (int i = 0; i < b.length; i++) {
			System.out.println(b[i]);
		}
	}

	@Test
	public void testSplit2() {
		String a = "    asdffg safaf    ";
		StringTokenizer s = new StringTokenizer(a);
		while (s.hasMoreTokens()) {
			System.out.println(s.nextToken());
		}
	}

	@Test
	public void test1() {
		String fn = "/home/hbui/kratos_janosch/mixed-mesh-sample.gid.msh";
		MeshGenerator mg = new GidMeshGenerator(fn);
		ArrayList<double[]> nodes = mg.getNodes(2);
		for (int i = 0; i < nodes.size(); i++) {
			Debugger.watch(i + ": ", nodes.get(i));
		}
		ArrayList<ArrayList<Integer>> conn = mg.getConnectivities();
		for (int i = 0; i < conn.size(); i++) {
			System.out.print(i + ": ");
			for (int j = 0; j < conn.get(i).size(); j++) {
				System.out.print(conn.get(i).get(j) + " ");
			}
			System.out.println();
		}
	}
}
